package model.area_effect;

import model.core.Logger;
import model.effects.Effect;
import model.entity.Entity;

/**
 * This class describes a trap on the game map.
 * @author Zachary
 *
 */
public class Trap extends AreaOfEffect implements Cloneable{
	private boolean isVisible;
	private String visibleGraphicID;
	
	/**
	 * Constructor for a Trap.
	 * @param name
	 * @param graphicID
	 * @param effect
	 * @param visibleGraphicID
	 */
	public Trap(String name, String graphicID, Effect effect,
			String visibleGraphicID) {
		super(name, graphicID, effect);
		this.isVisible = false;
		this.visibleGraphicID = visibleGraphicID;
	}
	
	/**
	 * Use apply trap to entity.
	 */
	public void interact(Entity entity) {
		entity.applyTrap(this);
		this.isVisible = true;
		Logger.getInstance().writeToLogger("It's a trap!");
	}
	
	/**
	 * Update the getGraphicID() to take into
	 * account visibility.
	 */
	public String getGraphicID(){
		String ret = null;
		if(!isVisible)
			ret = super.getGraphicID();
		else
			ret = visibleGraphicID;
		return ret;
	}

	/**
	 * Clone the trap.
	 */
	public Trap clone() throws CloneNotSupportedException {
		return (Trap)super.clone();
	}
}
